package com.gs.control;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.gs.model.MyEclipse;
import com.gs.util.ConfigUtil;

public class MainControl {
	public MyEclipse getMyEclipseConfig(){
		MyEclipse myEclipse=new MyEclipse();
		List<String> listPath=ConfigUtil.getMyEclipsePathBySigar();//ConfigUtil.getMyEclipsePath();
		List<String> wpList = new ArrayList<String>();
		Map<String,List<String>> pjMap=new HashMap<String,List<String>>();
		myEclipse.setPaths(listPath);
		if(listPath.size()>0) {
			for(String path:listPath){
				List<String> list=ConfigUtil.getWorkspaces(path);
				if(list.size()>0)
					wpList.addAll(list);//\.metadata\.plugins\org.eclipse.core.resources\.projects
			}			
		}
		if(wpList.size()>0) {
			for(String path:wpList){
				List<String> projects=getProjects(path);
				if(projects.size()>0) {
					pjMap.put(path, projects);
				}
			}
		}
		myEclipse.setProjects(pjMap);
		myEclipse.setWorkspaces(wpList);
		return myEclipse;
	}

	public MyEclipse getMyEclipse() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> getProjects(String path) {
		return ConfigUtil.getProjects(path);
		// TODO Auto-generated method stub
		
	}
	
}
